package org.hzandyy.framework.liteflow.resp;

import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.math.RandomUtils;
import org.hzandyy.framework.liteflow.context.CustomContext;
import org.hzandyy.framework.liteflow.support.Obj;

/**
 * @author hz
 * @since 2023/12/8 14:30
 */
@LiteflowComponent(value = "business", name = "businessName")
@Slf4j
public class BusinessCmp extends NodeComponent {
    @Override
    public void process() throws Exception {
        if (RandomUtils.nextBoolean()) {
            log.info("process error...");
            this.getContextBean(CustomContext.class).setData("business", new Obj("error"));
            throw new RuntimeException("出现运行错误");
        } else {
            log.info("process success...");
            this.getContextBean(CustomContext.class).setData("business", new Obj("success"));
        }
    }
}
